package test.aat.ejinr.test;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("SubGrid")
public class SubGrid extends HttpServlet {
  private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SubGrid() {
        super();
        // TODO Auto-generated constructor stub
    }

  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doPost(request,response);
  }

  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String id = request.getParameter("id");
    int iId = Integer.parseInt(id);
    String jsondata = "{}";
    switch (iId) {
    case 13:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"1\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 13\",\"1.00\",\"1000.00\",\"1 000.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 12:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 2\",\"1.00\",\"400.00\",\"400.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 4\",\"1.00\",\"300.00\",\"300.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 11:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"4\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 1\",\"2.00\",\"100.00\",\"200.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 2\",\"3.00\",\"50.00\",\"150.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"3\"," +
          "        \"cell\":[\"3\",\"item 3\",\"1.00\",\"50.00\",\"50.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"4\"," +
          "        \"cell\":[\"4\",\"item 4\",\"1.00\",\"200.00\",\"200.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 10:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 4\",\"1.00\",\"70.00\",\"70.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 5\",\"3.00\",\"10.00\",\"30.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 9:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 3\",\"1.00\",\"60.00\",\"60.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 6\",\"1.00\",\"140.00\",\"140.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 8:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"3\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 2\",\"1.00\",\"120.00\",\"120.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 3\",\"1.00\",\"50.00\",\"50.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"3\"," +
          "        \"cell\":[\"3\",\"item 3\",\"1.00\",\"30.00\",\"30.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 7:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 1\",\"1.00\",\"100.00\",\"100.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 5\",\"2.00\",\"10.00\",\"20.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 6:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"1\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 4\",\"1.00\",\"50.00\",\"50.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 5:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"1\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 3\",\"1.00\",\"100.00\",\"100.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 4:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 1\",\"1.00\",\"100.00\",\"100.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 2\",\"1.00\",\"50.00\",\"50.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 3:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 3\",\"1.00\",\"100.00\",\"100.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 4\",\"1.00\",\"200.00\",\"200.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 2:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 1\",\"2.00\",\"20.00\",\"40.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 2\",\"4.00\",\"40.00\",\"160.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    case 1:
      jsondata = "{" +
          "    \"page\":\"1\"," +
          "    \"total\":1," +
          "    \"records\":\"2\"," +
          "    \"rows\":[" +
          "      {" +
          "        \"id\":\"1\"," +
          "        \"cell\":[\"1\",\"item 1\",\"1.00\",\"20.00\",\"20.00\"]" +
          "      }," +
          "      {" +
          "        \"id\":\"2\"," +
          "        \"cell\":[\"2\",\"item 2\",\"2.00\",\"40.00\",\"80.00\"]" +
          "      }" +
          "    ]" +
          "  }";
      break;
    default:
      break;
    }
    
    response.getWriter().write(jsondata);
    
  }

}


			
